import React, { Component } from 'react';
import { Text, View,StyleSheet,Alert,Button,TextInput,Dimensions,Image} from 'react-native';
//导入Action的包,处理页面跳转
import { Actions } from 'react-native-router-flux';
const width = Dimensions.get('window').width;
export default class Header extends Component {
    constructor(props){
        super(props);
        this.state = {
        }
    }

    render(){
        console.log(Actions,"this.props.navigation")
        return (
            <View style={styles.headerBox}>
            {/*头部的左边*/}
                <Text style={styles.headerLeft} onPress={()=>{
                    console.log(11111)
                    Actions.pop({popNum:1})
                }}>
                    返回
                </Text>
                {/*头部的中间内容*/}
                 <Text style={styles.headerCentent}>{this.props.name}</Text>
                 {/*头部的右边*/}
                {
                !!this.props.rightTitle?<Text style={styles.headerRight}>{this.props.rightTitle}</Text>:null
               }
            </View>

        );
    }
};
const styles = StyleSheet.create({
      headerBox:{
          height:49,
          width:width,
          paddingLeft:15,
          paddingRight:15,
          fontSize:14,
          backgroundColor:'#fafafa',
      },
        headerLeft:{
            position:'absolute',
            left:15,
            top:0,
            width:50,
            height:49,
            lineHeight:49,
            zIndex:1,
            color:'#ccc'
        },
        headerRight:{
            position:'absolute',
            right:15,
            top:0,
            width:50,
            height:49,
            lineHeight:49,
            zIndex:1,
            color:'#ccc'
        },
        headerCentent:{
            flex:1,
            flexDirection: 'row',
            textAlign:'center',
            height:49,
            lineHeight:49,
            fontSize:18,
            fontWeight:'bold',
            color:'#000'
        }

});